/**
 * 气筒
 */
Pump18 = Widget.extend({
	runningAction:null,
	runningAction1:null,
	ctor:function(parent){
		this._super();
		parent.addChild(this,30);
		this.setTag(TAG_PUMP);
		this.init();
	},
	init : function(){
		this.setVisible(false);
		this.setCascadeOpacityEnabled(true);

		var pump1=new Button(this,10,TAG_PUMP1,"#run/barrel2.png",this.callback);
		pump1.setPosition(cc.p(600, 300));
		
		var pump=new Button(this,11,TAG_PUMP1,"#run/barrel1.png",this.callback);
		pump.setPosition(cc.p(600, 300));
		
		var handle=new Button(this,10,TAG_HANDLE,"#run/handle1.png",this.callback);
		handle.setPosition(cc.p(800, 300));
		
		var handle1=new Button(this,10,TAG_HANDLE1,"#run/handle.png",this.callback);
		handle1.setPosition(cc.p(598,600));
		handle1.setVisible(false);
		
		var lid=new Button(this,12,TAG_LID,"#run/lid1.png",this.callback);
		lid.setPosition(cc.p(600, 540));
		lid.setVisible(false);
		
		var lid1=new Button(this,11,TAG_LID1,"#run/lid2.png",this.callback);
		lid1.setPosition(cc.p(600, 540));
		lid1.setVisible(false);
	},
	handleMove:function(){
		var handle1=this.getChildByTag(TAG_HANDLE1);
		handle1.runAction(cc.moveBy(1,cc.p(0,-80)));
	},
	lidMove:function(){
		var lid=this.getChildByTag(TAG_LID);
		lid.runAction(cc.moveBy(1, cc.p(0,-80)));
	},
	lid1Move:function(){
		var lid1=this.getChildByTag(TAG_LID1);
		lid1.runAction(cc.moveBy(1,cc.p(0,-80)));
	},
	callback:function(p){
		var func=cc.callFunc(function() {
			gg.flow.next();
		}, this);
		switch (p.getTag()) {
		case TAG_HANDLE:
			var handle1=this.getChildByTag(TAG_HANDLE1);
			var lid=this.getChildByTag(TAG_LID);
			var lid1=this.getChildByTag(TAG_LID1);
			var ber=cc.bezierBy(1, [cc.p(-50,150),cc.p(-200, 300),cc.p(-200,300)]);
			p.runAction(cc.sequence(ber,cc.callFunc(function() {
				p.setVisible(false);
				handle1.setVisible(true);
				lid.setVisible(true);
				lid1.setVisible(true);
			}, this),cc.callFunc(function() {
				this.handleMove();
				this.lidMove();
				this.lid1Move();
			}, this),cc.delayTime(1),cc.callFunc(function() {
				p.removeFromParent(true);
			}, this),func));
			break;
		case TAG_HANDLE1:
			var move=cc.moveBy(0.3,cc.p(1,-120));
			p.runAction(cc.sequence(cc.spawn(move,cc.sequence(cc.delayTime(0.2),cc.callFunc(function() {
				ll.run.cotton.fadeoutCotton();
				ll.run.cotton.fadeinSpark();
			}, this))),cc.callFunc(function() {
				ll.run.cotton.fadeoutSpark();
				ll.run.cotton.fadeinCotton1();
				this.showTip=new ShowTip("通过压缩气体，使气体内能增加" +
						"\n，温度升高，从而引燃棉花",cc.p(gg.width*0.75, gg.height*0.5),true);
			}, this),func));
			break;
		default:
			break;
		}
	}
});
